package com.fujifilm.project.plan.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.fujifilm.project.plan.service.IUserService;
import com.fujifilm.project.plan.utils.HttpResponse;
import com.fujifilm.project.plan.vo.request.RequestRecords.UserLoginRequest;
import com.fujifilm.project.plan.vo.response.ResponseRecords.UserInfoResponse;
import com.fujifilm.project.plan.vo.response.ResponseRecords.UserLoginResponse;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@RestController
@RequestMapping("/user")
@Slf4j
@RequiredArgsConstructor
public class UserController {
    private final IUserService userService;

    @PostMapping("/login")
    public HttpResponse<UserLoginResponse> login(@RequestBody UserLoginRequest userLoginRequest) {
        UserLoginResponse resp = userService.login(userLoginRequest);
        return HttpResponse.success(resp);
    }

    @PostMapping("/logout")
    public HttpResponse<Void> logout() {
        // 这里可以添加登出逻辑，比如清除会话或令牌
        // 目前只是返回一个简单的字符串
        userService.logout();
        return HttpResponse.success(null);
    }

    @PostMapping("/info")
    public HttpResponse<UserInfoResponse> info() {
        // 这里可以返回用户信息
        // 目前只是返回一个简单的字符串
        return HttpResponse.success(userService.info());
    }
}
